# 转换为整数int
# 字符串str-->整数int
# 纯数字的字符串才可以转换
s = "2025"
s1 = int(s)
print("-"*10, "字符串", "-"*10)
print(type(s), type(s1))
# s3 = "aaa123"
# s3 = int(s3)
# print(s3)  #会出现报错信息（字符串中也不能是浮点数）

# 浮点数float-->整数int
s2 = 2.123
s3 = int(s2)
print("-"*10, "浮点数", "-"*10)
print(type(s2), type(s3))

# 布尔bool-->整数int
s4, s5 = True, False
s4 = int(s4)
s5 = int(s5)
print("-"*10, "布尔类型", "-"*10)
print(type(s4), type(s5))
print(s4, s5)

# 转行成float类型
print("*"*15, "转换成浮点数", "*"*15)
# int --> float
print(float(s))
# str --> float
s7 = "12.5"
s8 = "12"
print(float(s7), float(s8))
# bool-->float
print(float(s4), float(s5))

# 转行成str类型
print("*"*15, "字符串", "*"*15)
# int --> str
s9 = 2025
print(str(s9), type(str(s9)))
# float --> str
print(str(s2), type(str(s2)))
# bool --> str,直接一整数（0/1）的形式输出
print(str(s4))

# 转换成bool 类型
print("*"*15, "布尔类型", "*"*15)
# int-->bool
print(bool(s9))
# float--> bool
print(bool(s2))
# str-->bool
str1 = ''
print(bool(str1))  # False
str2 = ' '
print(bool(str2))  # True

# 进制转换
str2 = '1a'
print(int(str2, 16))  # int(变量名，要转换成的进制）
str3 = '11'
print(int(str3, 2))  # 3
